﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Themes;
using System.Web.Mvc;
using Orchard;
using Orchard.Data;
using Orchard.Localization;
using Orchard.ContentManagement;
using Orchard.Logging;
using TekFlow.FamilyTree.Models;
namespace TekFlow.FamilyTree.Controllers
{
    
    public class HomeController : Controller
    {
        private readonly IRepository<FamilyMemberRecord> _familyMemberRepository;

        public HomeController(IRepository<FamilyMemberRecord> familyMemberRepository)
        {
            _familyMemberRepository = familyMemberRepository;
        }

        [HttpPost]
        public ActionResult AddTag(FamilyMemberRecord record)
        {
            _familyMemberRepository.Create(record);
 
            return Json(record);
        }

        [HttpPost]
        public ActionResult DeleteTag(int Id)
        {
            var del = _familyMemberRepository.Get(Id);
            if (del != null)
                _familyMemberRepository.Delete(del);
            return Json("success");
        }

        [HttpPost]
        public ActionResult StartingTags(int Id)
        {
            var all = _familyMemberRepository.Fetch(x => x.parentId == Id);
            return Json(all);
        }
    }
}